#ifndef _MENU_H_
#define _MENU_H_

#ifdef _WIN32
#pragma once
#endif

#include <vector>
#include <string>

#include "fmod.hpp"

#include "ui_text.h"
#include "option.h"
#include "keyboard.h"
#include "input.h"
#include "soundmanager.h"

using std::string;
using std::vector;

class CMenu : public CUIText
{
public:
    CMenu(float x, float y);
    virtual ~CMenu();
    
    //COption* add_option(string path, string apath, int sizeX, int sizeY);
    COption* addOption(string szText, int nPositionX, int nPositionY);

    void removeOption(int index);
    virtual COption* getOption(int index) const;
    virtual size_t getOptionCount() const;

    void incrementSelection();
    void decrementSelection();
    int getCurrentSelectionIndex() const;
    COption *getCurrentOption() const;

    // Event callback
    virtual void onChange(COption *pOldOption,
        COption *pNewOption) {}
    virtual void onSelected(COption *pOption) {}
    virtual void onActivate() {}
    virtual void onDeactivate() {}

    void setTitle(const string &szTitle, float fXOffset, float fYOffset);
    string getTitle() const;

    //void update();
    void render();

    virtual void callSelected(unsigned char chKey);

    void handleInput(const DEVICE_EVENT &evt);

    void setActiveColour(float red, float green, float blue, float alpha);
    void setInactiveColour(float red, float green, float blue, float alpha);

    bool isActive() const;
    void setActive(bool bActive);

    float getLeft() const;
    float getTop() const;
private:
    vector<COption*> m_arrOptions;
    
    unsigned int m_nSelected; 

    bool m_bActive;

    float m_fX;
    float m_fY;

    float getMenuHeight();
    float getMenuWidth();
};

#endif